package com.skcc.cop.mrtaxi4driver.util;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;

import com.skcc.cop.mrtaxi4driver.R;


public class Dialogs {
	
	private static AlertDialog dialog;
	
	public interface DialogListener {
		
		public void onClickedOk();
		public void onClickedCancel();
	}
	
	
	public static void dismiss() {
		if (dialog != null) {
			dialog.dismiss();
		}
	}
	
	public static void showDialogYesNo(Context context, String message, final DialogListener listener) {
    	
    	LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    	View customTitleView = inflater.inflate(R.layout.view_customtitle, null, false);
    	
    	dialog = new AlertDialog.Builder(context)
				.setCustomTitle(customTitleView)
				.setMessage(message)
				.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						listener.onClickedOk();
					}
				}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						listener.onClickedCancel();
					}
				}).show();
	}
	
	
	public static void showDialog(Context context, String message, final DialogListener listener) {
    	
    	LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    	View customTitleView = inflater.inflate(R.layout.view_customtitle, null, false);
    	
    	dialog = new AlertDialog.Builder(context)
				.setCustomTitle(customTitleView)
				.setMessage(message)
				.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						listener.onClickedOk();
					}
				}).show();
	}
	
}
